<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        body{
            background-image: url(../bao/imgs/register.jpg);
            background-size: 100%;
        }
        .form {
            width: 450px;
            box-shadow: 0px 0px 6px #ccc;
            margin: 150px auto;
            padding: 20px 0 50px 0;
            text-align: center;
            background-color: rgba(255, 255, 255, 0.5);
        }

        .form input {
            height: 25px;
            width: 74%;
            padding-left: 10px;
            border: 0;
            border-bottom: 1px solid #808080;
            outline: 0;
            margin: 40px auto 15px auto;
            display: block;
            font-size: 16px;
            background-color: rgba(255, 255, 255, 0);
        }

        #request {
            width: 90%;
            height: 35px;
            display: block;
            border: 0;
            border-radius: 20px;
            margin: 50px auto 20px auto;
            color: white;
            background-color: #619026;
        }
    </style>

</head>

<body>


    <div class="form">

        <h2>注册</h2>

        <input type="text" id="username" placeholder="用户名">

        <input type="password" id="password" placeholder="密码">

        <input type="password" id="queren" placeholder="确认密码">

        <button id="request">注册</button>

        <a href="/" style="float: right;margin-right: 40px;">登录页面</a>
    </div>


</body>

<script>


    request.onclick = function () {

        let xhr = new XMLHttpRequest();


        xhr.onreadystatechange = function () {
            location.href = "/"
        }


        xhr.open('post', `/register`, true); // 请求方法、请求路径、是否异步（默认是true-异步，false是同步）
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded")

        xhr.send(`username=${username.value}&password=${password.value}`);

    }


</script>


</html>